﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Text;

namespace NASA.BeAMartian.Extender
{
    public static class StringExtensions
    {
        public static string Capitalize(this string s)
        {
            if(s == null)
                return null;

            if(s.Length == 0)
                return s;

            char [] ret= new char[s.Length];

            ret[0] = char.ToUpper(s[0]);
            for(int index = 1; index < s.Length; index++)
            {
                ret[index] = char.ToLower(s[index]);
            }

            return new string(ret, 0, ret.Length);
        }

        public static string PrefixUppercaseChars(this string s, string repl)
        {
            StringBuilder builder = new StringBuilder();
  
            for(int n = 0; n < s.Length; n++)
            {
                char c = s[n];
                if (char.IsUpper(c))
                    builder.Append(repl);
                builder.Append(c);
            }

            return builder.ToString();
        }
    }
}
